package com.lkxicy.wos.utils;


import java.io.Serializable;

/**
 * 返回的json响应体
 *
 * @author FengJingdong
 */
public class Response implements Serializable {

    /**
     * 表示当前相应的状态是成功或者失败
     */
    private String code;
    /**
     * 表示当响应失败之后给前端的错误提示
     */
    private String msg;
    /**
     * 表示当响应成功之后返回给前端的数据
     */
    private Object data;

    public static Response success(Object data) {
        return new Response("200", "请求成功", data);
    }



    public static Response success(String msg, Object data) {
        return new Response("200", msg, data);
    }

    public static Response success() {
        return new Response("200", "请求成功", null);
    }

    public static Response error(String msg) {
        return new Response("500", msg, null);
    }

    public static Response error(String code, String msg) {
        return new Response(code, msg, null);
    }

    public static Response error(int code, String msg) {
        return new Response(String.valueOf(code), msg, null);
    }


    public static Response buildCustom(int code, String msg) {
        return new Response(String.valueOf(code),msg,null);
    }

    public static Response setShortMsg(Integer code, String msg) {
        return new Response(String.valueOf(code), msg, null);
    }

    public static Response setCodeMsgData(Integer code,String msg,Object data){
        return new Response(String.valueOf(code), msg,data);
    }
    private Response() {
    }

    public Response(String code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
